home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / profile.arc / PROFILE.DOC < prev    next >
Encoding:
Text File  |  1985-11-28  |  6.5 KB  |  198 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.      PROFILE (1)           Program Execution Profiler           PROFILE (1)
  69.  
  70.  
  71.  
  72.      NAME   
  73.      NAME 
  74.           profile - program profiler 
  75.  
  76.  
  77.      SYNOPSIS   
  78.      SYNOPSIS 
  79.           profile program progarg1 progarg2    progargn   
  80.           profile program progarg1 progarg2 .. progargn 
  81.  
  82.  
  83.      DESCRIPTION   
  84.      DESCRIPTION 
  85.           profile                                                       
  86.           profile  is used to determine where a program spends most of
  87.           its time executing, in order  to  determine  where  in  that
  88.           program it will be profitable to optimize.  When invoked, it 
  89.                        program                    progarg1 progarg2     
  90.           will  run    program    ,passing  along progarg1 progarg2 ..
  91.           progargn     program s                                        
  92.           progargn as  program's command  line.    After  the  program
  93.           being profiled terminates, a list of addresses is printed to 
  94.           the  standard  output,  along  with  the number of times the
  95.                                program                     
  96.           profiler interrupted program at that address.  
  97.  
  98.  
  99.                 SH EXAMPLE 
  100.                 profile tester.exe
  101.                 cs=607c
  102.                 003c : 40
  103.                 0040 : 141
  104.                 0044 : 12
  105.                 0048 : 5
  106.                 004c : 1
  107.                 0050 : 8
  108.                 0054 : 3
  109.                 0058 : 7
  110.                 0060 : 10
  111.                 0064 : 5
  112.                 0068 : 8
  113.                 0710 : 1
  114.  
  115.  
  116.                                      tester exe                          
  117.           What happened here is that tester.exe was executed, and that 
  118.           profile                                                       
  119.           profile was of the opionion that it spent most of  its  time
  120.           right around cs:0040.  
  121.  
  122.  
  123.  
  124.      IMPLEMENTATION   
  125.      IMPLEMENTATION 
  126.           Profile                                                        
  127.           Profile is only able to interrupt the program being profiled 
  128.           18.2 times  per  second.    That  means that in order to get
  129.           meaningful results, your program must take longer than a few 
  130.           seconds to execute, and that it not be  I/O  bound.    That,
  131.           fortunately,  is  a  fairly  good  definition of the sort of
  132.           programs that need profiling.  
  133.  
  134.  
  135.                                                                cs 607c   
  136.           You may have noticed that in the above example that  cs=607c 
  137.           was printed  out  before  the  profile  information.    That
  138.                                                         regs exe        
  139.           message  was actually  printed by the program regs.exe, that
  140.                          profile com                                    
  141.           was invoked by profile.com  to  determine  where  MSDOS  was
  142.                                         Regs exe                        
  143.           going to  load  tester.exe.   Regs.exe figures out where its
  144.           loaded, and writes this  out  to  a  temporary  file  called
  145.           register         profile com                                  
  146.           register, which  profile.com then reads in.  This process is
  147.           necessary because there is no other way  to  determine  wher
  148.           MS-DOS is going to load a program.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.                                       -1-
  157.  
  158.  
  159.  
  160.      PROFILE (1)           Program Execution Profiler           PROFILE (1)
  161.  
  162.  
  163.  
  164.           Even  stranger,  it  is  necessary  to also have the program
  165.           regs com                                       com             
  166.           regs.com available if you want to profile a  '.com' program, 
  167.                            com                                          
  168.           as MS-DOS puts '.com' programs in  a  different  place  than
  169.             exe               
  170.           '.exe' programs.  
  171.  
  172.  
  173.           This  program was compiled with the Manx Aztec C86 compiler.
  174.           I have put in  conditional  assembly  flags  to  ease  using
  175.           Lattice,  but  there  is one difference that will have to be
  176.                                  fexecv                                 
  177.           dealt with.  The Aztec fexecv library function  expects  the
  178.            exe  com                                                     
  179.           .exe|.com  extension  in  its  specified  file  name,  where
  180.                     forkv                                               
  181.           Lattice's forkv does not.   So,  you  will  have  to  use  a
  182.           different  method  than I did to determine whether a program
  183.                  com       exe                                          
  184.           is an .com or a .exe program.  I might suggest  opening  the
  185.                                        exe                              
  186.           file  and  looking  for the .exe 'magic number' bytes at the
  187.           beginning of the file (4DH and 5A). This will  unfortunately
  188.           slow things down a bit more, but that's life in PC-DOS.  
  189.  
  190.  
  191.           The  assembly  source  files  might  need  some massaging to
  192.           coincide with the way Lattice wants the segments defined  in
  193.           assembly subroutines.  I didn't bother to put in conditional 
  194.           assembly   directive  to  accomadate  Lattice,  because  the
  195.           conversion process should be  straightforward,  and  a  good
  196.           excersise for 'porting hackers.' 
  197.  
  198.  
  199.           If  anyone  out  there  cares,  the  Manx Aztec C86 compiler
  200.           (version 3 and later) makes the Lattice compiler look pretty 
  201.           limp, and is  a  lot  more  straightforward  to  work  with.
  202.           Documentation   and  supporting  tools  are  excellent,  and
  203.           performance is unparalleled.  It lives up to the  claims  in
  204.           their  somewhat  incoherent  ads,  and  I'd  recommend it to
  205.           anyone doing serious work with C.  
  206.  
  207.  
  208.      ENHANCEMENTS   
  209.      ENHANCEMENTS 
  210.           A more graphic way of displaying profiler results  would  be
  211.           nice,  but  a  more  useful  enhancement  would  be to merge
  212.           profile s                                                     
  213.           profile's output  with  the  symbol  table  output  of  your
  214.           compiler of choice.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.                                       -2-
  240.  
  241.  
  242.